import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName } from '@/config'

// 修改下面部分，可减少出现不明bug
//管理员登录
export async function login(data) {
  if (loginRSA) {
    data = await encryptedData(data)
  }
  return request({
    url: '/api/admin/adminLogin',
    method: 'post',
    data,
  })
}
//管理员退出
export function logout(accessToken) {
  return request({
    url: '/api/admin/adminLogout',
    method: 'post',
    data: { accessToken: accessToken },
  })
}

//获取用户信息
export function getUserInfo(accessToken) {
  return request({
    url: '/api/admin/adminInfo',
    method: 'post',
    data: { accessToken: accessToken },
  })
}

export function register() {
  return request({
    url: '/register',
    method: 'post',
  })
}
